<template>
	<view v-show="isLogin === 1" class="mine">
		<!-- 背景 -->
		<image class="mine_bg" mode="widthFix" :src="$imgUrl('/mine/bg-mine.png')"></image>

		<!-- 用户信息 -->
		<view class="mine-header" @click="goInfo">
			<image class="mine-header__avatar" :src="userInfo.avatar" mode="widthFix"></image>
			<view class="mine-header__info">
				<view class="mine-header__info__name">{{ userInfo.userName || '' }}</view>
				<view class="mine-header__info__phone">{{ userInfo.phone || '' }}</view>
			</view>
			<image class="mine-header__set" mode="widthFix" :src="$imgUrl('/mine/icon-set.png')"></image>
		</view>

		<!-- 账户价格 -->
		<view class="mine-balance" @click="toDetails">
			<view class="mine-balance__title">账户余额(元)</view>
			<view class="mine-balance__price">¥{{ userInfo.balance }}</view>
			<view class="mine-balance__topay">明细</view>
		</view>
		<!-- 会员卡标签 -->
		<!-- <view class="member">
			<view class="leftview">
				<view class="image">
					VIP 会员卡
				</view>
				<view class="title">
					<text v-if="userInfo.vip == 0">仅需￥{{typeslist.money}}，30天最高可省{{typeslist.credit}}元</text>
					<text v-else>会员至{{userInfo.time}}日到期</text>
				</view>
			</view>
			<view class="btn">{{userInfo.vip == 0 ? '立即开通' : '立即续费'}}</view>
		</view> -->
		<!-- 会员优惠额度，账户余额 -->
		<!-- <view class="pricebox">
			
			<view class="list">
				<view class="title">会员优惠额度(元)</view>
				<view class="viewbtn">
					<text style="font-size: 25rpx;" v-if="userInfo.vip == 0 ">去充值</text>
					<text v-else>{{Number(userInfo.discounts).toFixed(2)}}</text>
					<image src="https://bhzhtc.oss-cn-beijing.aliyuncs.com/sxsd/a92e5b5d24aa4e2aac99acd4c19552af.png"
						mode=""></image>
				</view>
			</view>
			<view style="width: 20rpx;"></view>
			
			<view class="list" @click="toDetails">
				<view class="title">账户余额(元)</view>
				<view class="viewbtn">
					<text>{{userInfo.balance}}</text>
					<image src="https://bhzhtc.oss-cn-beijing.aliyuncs.com/sxsd/a92e5b5d24aa4e2aac99acd4c19552af.png"
						mode=""></image>
				</view>
			</view>
		</view> -->
		<!-- 我的订单 -->
		<view class="mine-order">
			<view class="mine-order__title">
				<view class="mine-order__title__left">我的订单</view>
				<view class="mine-order__title__right" @click="toMyOrder">
					全部订单
					<image class="mine-order__title__icon" mode="widthFix" :src="$imgUrl('/mine/icon-title.png')">
					</image>
				</view>
			</view>
			<view class="mine-tag">
				<view class="mine-tag__box" v-for="(item,index) in tagListOrder" :key="index" @click="toDoing(item)">
					<image class="mine-tag__box__icon" mode="widthFix" :src="$imgUrl(item.icon)"></image>
					<view>{{ item.text }}</view>
				</view>
			</view>
		</view>

		<!-- 常用功能 -->
		<view class="mine-ability">
			<view class="mine-ability__title">常用功能</view>
			<view class="mine-tag">
				<view v-if="userInfo.authStatus == null || userInfo.authStatus == 2" class="mine-tag__box"
					@click="toDoing(auther)">
					<image class="mine-tag__box__icon" mode="widthFix" :src="$imgUrl(auther.icon)"></image>
					<view>{{ auther.text }}</view>
				</view>
				<view class="mine-tag__box" v-for="(item,index) in tagListAbility" :key="index" @click="toDoing(item)">
					<image class="mine-tag__box__icon" mode="widthFix" :src="$imgUrl(item.icon)"></image>
					<view>{{ item.text }}</view>
				</view>
			</view>
		</view>

		<!-- 客服电话 -->
		<view class="mine-service__phone">
			<image class="mine-order__title__icon" mode="widthFix" :src="$imgUrl('/mine/icon-kphone.png')"></image>
			统一客服电话：0370-78989093
		</view>

		<systemSpecial v-if="showWindow" @closeWindow="closeWindow" />
	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex'
	import systemSpecial from '@/components/systemSpecial.vue'
	export default {
		components: {
			systemSpecial
		},
		data() {
			return {
				tagListOrder: [{
					text: '待付款',
					icon: '/mine/icon-tag1.png',
					pageUrl: '/pages/order/orderList/index?status=1'
				}, {
					text: '待发货',
					icon: '/mine/icon-tag2.png',
					pageUrl: '/pages/order/orderList/index?status=2'
				}, {
					text: '待收货',
					icon: '/mine/icon-tag3.png',
					pageUrl: '/pages/order/orderList/index?status=3'
				}, {
					text: '售后/退款',
					icon: '/mine/icon-tag4.png',
					pageUrl: '/pages/order/orderList/index?status=4'
				}],
				tagListAbility: [{
					text: '收货地址',
					icon: '/mine/icon-tag6.png',
					pageUrl: '/pages/address/index'
				}, {
					text: '系统专员',
					icon: '/mine/icon-tag7.png',
					pageUrl: ''
				}],
				auther: {
					text: '实名认证',
					icon: '/mine/icon-tag5.png',
					pageUrl: '/pages/mine/auther/index'
				},
				showWindow: false,
				typeslist: {}
			}
		},
		computed: {
			...mapState(['isLogin', 'userInfo'])
		},
		onReady() {
			this.$apis.paymemberlimit.types({
				type: 'member_level'
			}).then(res => {
				this.typeslist = res.data[0]
			})
		},
		onShow() {
			if (this.isLogin === 1) {
				this.getUserInfo()
			} else if (this.isLogin === 2) {
				this.login()
			}
		},
		methods: {
			...mapActions(['getUserInfo', 'login']),
			toDoing(item) {
				switch (item.text) {
					case '系统专员':
						this.showWindow = true
						break;
					default:
						uni.navigateTo({
							url: item.pageUrl
						})
						break;
				}
			},
			closeWindow() {
				this.showWindow = false
			},
			toMyOrder() {
				uni.navigateTo({
					url: '/pages/order/orderList/index'
				})
			},
			toDetails() {
				uni.navigateTo({
					url: '/pages/mine/consumerDetail/index'
				})
			},
			paytourl() {
				if (this.userInfo.vip == 0) {
					uni.navigateTo({
						url: '/pages/mine/member/spay'
					})
				} else {
					uni.navigateTo({
						url: '/pages/mine/member/xpay'
					})
				}

			},
			goInfo() {
				uni.navigateTo({
					url: `/pages/wxNickname/wxNickname?avatar=${this.userInfo.avatar}&nickName=${this.userInfo.userName}`
				})
			},
			toedpay() {
				if (this.userInfo.vip == 0) {
					uni.navigateTo({
						url: '/pages/mine/member/spay'
					})
				} else {
					uni.navigateTo({
						url: '/pages/mine/member/edlist'
					})
				}

			}
		}
	}
</script>

<style scoped lang="scss">
	.mine {
		min-height: 100vh;
		background: #F6F6F6;
		position: relative;
		padding: 24rpx;

		.mine_bg {
			position: absolute;
			left: 0;
			top: 0;
			width: 750rpx;
			height: 750rpx;
			z-index: -1;
		}

		.mine-header {
			height: 120rpx;
			display: flex;
			position: relative;
		}

		.mine-header__avatar {
			width: 120rpx;
			height: 120rpx;
			border-radius: 60rpx;
		}

		.mine-header__info {
			margin-left: 24rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-around;

			.mine-header__info__name {
				font-size: 34rpx;
				font-weight: bold;
				color: #333333;
			}

			.mine-header__info__phone {
				font-size: 24rpx;
				color: #333333;
			}
		}

		.mine-header__set {
			width: 54rpx;
			height: 54rpx;
			position: absolute;
			top: 0;
			right: 0;
		}

		.mine-balance {
			height: 124rpx;
			padding: 32rpx;
			background: linear-gradient(270deg, #2FCC71 0%, #1EB75E 100%);
			border-radius: 24rpx;
			margin-top: 32rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			position: relative;
		}

		.mine-balance__title {
			font-size: 28rpx;
			color: #FFFFFF;
		}

		.mine-balance__price {
			font-size: 44rpx;
			font-weight: bold;
			color: #FFFFFF;
		}

		.mine-balance__topay {
			position: absolute;
			right: 24rpx;
			bottom: 24rpx;
			width: 120rpx;
			height: 48rpx;
			background: #FFFFFF;
			border-radius: 36rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 24rpx;
			font-weight: bold;
			color: #2FCC71;
		}

		.member {
			height: 120rpx;
			margin-top: 20rpx;
			display: flex;
			justify-content: space-between;
			padding: 0 40rpx 0 32rpx;
			box-sizing: border-box;
			align-items: center;
			background-image: url(https://bhzhtc.oss-cn-beijing.aliyuncs.com/sxsd/ac33c6e7f11a4833a97f2ca7e0ade9fd.png);
			background-size: 100% 100%;
			background-repeat: no-repeat;

			.leftview {

				.image {
					background: linear-gradient(to right, #FFE5C2, #F1C68E);
					-webkit-background-clip: text;
					-webkit-text-fill-color: transparent;
					font-size: 32rpx;
					font-weight: 700;
					height: 40rpx;
					margin-bottom: 9rpx;
				}

				.title {
					font-size: 24rpx;
					color: #FFFFFF;
				}
			}

			.btn {
				width: 144rpx;
				height: 52rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				background-color: #FBE6C7;
				border-radius: 36rpx;
				font-size: 24rpx;
				color: #3F3F47;
			}
		}

		.pricebox {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 160rpx;
			margin-top: 20rpx;

			.list {
				background-color: #FFFFFF;
				border-radius: 24rpx;
				flex: 1;
				height: 160rpx;
				padding: 24rpx 24rpx 32rpx 32rpx;
				box-sizing: border-box;

				.title {
					color: #333333;
					font-size: 24rpx;
					font-weight: 700;
				}

				.viewbtn {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin-top: 26rpx;

					text {
						font-size: 31rpx;
						color: #000000;
						font-weight: 700;
					}

					image {
						width: 48rpx;
						height: 48rpx;
					}
				}
			}

		}

		.mine-order {
			padding: 24rpx 24rpx 34rpx 24rpx;
			height: 174rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			margin-top: 20rpx;

			.mine-order__title {
				display: flex;
				align-items: center;
				justify-content: space-between;
			}

			.mine-order__title__left {
				font-size: 30rpx;
				font-weight: bold;
				color: #333333;
			}

			.mine-order__title__right {
				font-size: 28rpx;
				color: #666666;
				display: flex;
				align-items: center;

				.mine-order__title__icon {
					width: 36rpx;
					height: 36rpx;
				}
			}
		}

		.mine-tag {
			display: flex;
			margin-top: 32rpx;

			.mine-tag__box {
				width: 133rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: space-between;
				font-size: 24rpx;
				color: #333333;
				margin-right: 30rpx;

				.mine-tag__box__icon {
					width: 54rpx;
					height: 54rpx;
					margin-bottom: 16rpx;
				}
			}
		}

		.mine-ability {
			padding: 24rpx 24rpx 34rpx 24rpx;
			height: 174rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			margin-top: 20rpx;

			.mine-ability__title {
				font-size: 30rpx;
				font-weight: bold;
				color: #333333;
			}
		}

		.mine-service__phone {
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 24rpx;
			color: #999999;
			margin-top: 100rpx;

			.mine-order__title__icon {
				width: 40rpx;
				height: 40rpx;
				margin-right: 8rpx;
			}
		}

	}
</style>